<template>
  <view class="chat-order" @click="handleClick">
    <view class="order-top">
      <u-image class="service-message__image" :src="getFilePath(data.cover)" />
      <view class="order-top-right">
        <view class="order-name">{{ data.name }}</view>
        <view class="order-content">
          <view class="order-actPrice">¥{{ data.actPrice || 0 }}</view>
          <view class="order-price">¥{{ data.price || 0 }}</view>
        </view>
      </view>
      <view class="order-bottom">
        <view>￥{{ data.actPrice || 0 }}</view>
        <view style="margin-left: 10px; margin-top: 6px"> x{{ data.count || 0 }}</view>
      </view>
    </view>
    <view class="order-line">
      <view class="order-remark">订单备注：{{ data.remark || '暂无' }}</view>
      <!-- 订单类： -->
      <view class="order-count">
        共{{ data.count }} 件 小计 <i>￥{{ data.actPrice || 0 }}</i>
      </view>
    </view>
  </view>
</template>
<script>
import { getFilePath } from '../../utils/common'

export default {
  name: 'OrderMessage',
  props: {
    item: {
      type: Object,
      default: () => ({
        avatar: '',
        m_data: {}
      }),
      required: true
    }
  },
  computed: {
    data() {
      return this.item.m_data
    },
    userType() {
      return this.$store.state.user.userType
    }
  },
  methods: {
    getFilePath,
    handleClick() {
      if (this.userType === '02' || this.userType === '03') {
        this.$router.push({ path: '/myInfo', query: { id: this.data.id, page: 'orderPage' }})
        if (this.$route.path === '/myInfo') {
          window.location.reload()
        }
      } else {
        this.$router.push({ path: '/orderForm/allOrder', query: { id: this.data.id, page: 'show' }})
        if (this.$route.path === '/orderForm/allOrder') {
          window.location.reload()
        }
      }
    }
  }
}
</script>
<style lang="scss" scoped>
  .chat-order {
    margin: 12px auto;
    padding: 10px 10px;
    min-width: 350px;
    height: 200px;
    background-color: #ffffff;
    box-shadow: 0px 1px 4px 0px rgba(0, 0, 0, 0.04);
    border-radius: 8px 8px 8px 0px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    max-width: 450px;

    .order-top {
      width: 100%;
      height: 90px;
      display: flex;

      .order-top-right {
        margin-left: 10px;

      }
    }

    .order-bottom {
      height: 50px;
    }

    .order-name {
      width: 133px;
      height: 42px;
      overflow: hidden;
      text-overflow: ellipsis;
      font-weight: 400;
      font-size: 16px;
      color: #333333;
    }

    .order-content {
      display: inline-block;
      margin-top: 6px;
      height: 29px;
      line-height: 29px;

      .order-actPrice {
        display: inline-block;
        margin-left: 10px;
        width: auto;
        font-weight: 400;
        font-size: 12px;
        color: #FF1F00;
      }

      .order-price {
        text-decoration: line-through;
        font-weight: 400;
        font-size: 11px;
        color: #999999;
        margin-left: 5px;
      }

      .order-actPrice {
        font-weight: 600;
      }
    }

    .order-line {
      width: 100%;
    }

    .order-remark {
      border-top: 1px solid #dddddd;
      border-bottom: 1px solid #dddddd;
      height: 45px;
      line-height: 45px;
    }

    .order-count {
      text-align: right;

      i {
        font-family: PingFangSC, PingFang SC;
        font-weight: 600;
        font-size: 11px;
        color: #111111;
        line-height: 20px;
      }
    }

    .order-count,
    .order-remark {
      margin-top: 4px;
      font-size: 0.9em;
      color: #585858;
    }
  }
</style>
